package com.t309.tzy.controller;
import com.t309.tzy.common.TSysUserConverter;
import com.t309.tzy.entity.TSysUser;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Date;
@Controller
@RequestMapping("/converter")
public class ConverterController {


    @GetMapping("toUser")
    //@RequestParam("user")用来指定参数名字, 把参数名的值转换为对象
    //converter/user?user=account:cloud,realName:李四
    public String toConverterUser(Model model){
        return "test";
    }
    //@ResponseBody
    @GetMapping("user")
    //@RequestParam("user")用来指定参数名字, 把参数名的值转换为对象
    //converter/user?user=account:cloud,realName:李四
    public String converterUser(@RequestParam("user") TSysUser user, Model model){
        System.out.println("user.realName="+user.getRealName());
        //user.setRealName("法外狂徒张三");
        //user.setAccount("zhs");
        //return TSysUserController;
        TSysUserConverter converter = new TSysUserConverter();
        //converter.convert(user);
        return "success";
    }

    @ResponseBody
    @GetMapping("/converter")
    public String converter(Date date){
        System.out.println("date="+date);
        return date.toString();
    }

    /**
     *
     * @param user
     * @return
     */
    public String converterUser2(@RequestParam("user") TSysUser user){
        return "";
    }

}
